<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>layui</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="__static/lib/layui-v2.5.5/css/layui.css" media="all">
	<link rel="stylesheet" href="__static/css/public.css" media="all">
	<style>
		.layui-form-pane .layui-form-label {
			width: 90px;
		}
	</style>
</head>
<body>
<div class="layuimini-container"> 
	<div class="layuimini-main">
		<fieldset class="table-search-fieldset">
			<legend>搜索信息</legend>
			<form class="layui-form layui-form-pane" action="">
				<div class="layui-form-item" style="margin-bottom: 5px;">
					<div class="layui-inline">
						<div class="layui-input-inline">
							<input type="text" name="sell_time" id="date" autocomplete="off" placeholder="请选择销售时间" class="layui-input">
						</div>
						<div class="layui-input-inline">
							<select name="customer_id"  autocomplete="off" lay-search="">
								<option value="">请选择客户</option>
								{volist name="Customer_list" id='pt'}
									<option value="{$pt.id}" >{$pt.name}</option>
								{/volist}
					        </select>
						</div>
					</div>
					<div class="layui-inline">
						<button type="button" class="layui-btn layui-btn-primary"  lay-submit="" lay-filter="search"><i class="layui-icon"></i> 搜 索</button>
					</div>
				</div>
			</form>
		</fieldset>
		
		<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
		<script type="text/html" id="currentTableBar">
			<a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="save">详情</a>
		</script>
		
	</div>
</div>
<script src="__static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="__static/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="__static/js/man.js" charset="utf-8"></script>
<script>

	var $,form,table,laydate
	layui.use(['form', 'table', 'tableSelect', 'laydate'], function () {
		$ = layui.jquery , form = layui.form , table = layui.table , laydate = layui.laydate
		 laydate.render({
			    elem: '#date', //指定元素
			  });
		//监听搜索提交
		  form.on('submit(search)', function(data){
			var articleFrom = data.field;
			table.reload('items_list', {
				  url: '{:url("sell_stat")}?t=json',
				  where:articleFrom
				});
			return false;
		  });
		  table.render({
				elem: '#currentTableId',
				id:'items_list',
				url: '{:url("sell_stat")}?t=json',
				method : 'post',
				toolbar: '#toolbarDemo',
				totalRow: true,
				cols: [[
					{ field: 'sell_time', title: '销售时间' ,  totalRowText: '合计',templet: function (d) {
	                    return date("Y-m-d",d.sell_time) 
	            	}},
					{ field: 'customer_name', title: '客户名称' },
					{ field: 'nums', title: '销售数量',totalRow: true},
					{ field: 'totals', title: '销售总价',totalRow: true},
					
				    { field: 'note', title: '备注'},
				    { field: 'media_name', title: '销售'},
				    { title: '操作', minWidth: 150, fixed: 'right', toolbar: '#currentTableBar',align:'center'}
				]],
				limit: 30,
				page: true,
				skin: 'line'
			});
		
		 
		
		table.on('tool(currentTableFilter)', function (obj) {
			var data = obj.data;
			switch (obj.event) {
				case 'save':
					get_info(data.customer_id,data.sell_time);
				break;
			}
		});
		

	});
	function get_info(customer_id,sell_time){
		layer.open({
	        type: 2,
	        title:'详情',
	        area: ['60%', '70%'],
	        fixed: false, //不固定
	        maxmin: true,
	        shadeClose:false,	//点击遮罩后关闭提示框
	        scrollbar:false, //- 是否允许浏览器出现滚动
	        content: "{:url('sell_info')}?customer_id="+customer_id+'&sell_time='+sell_time
	    });
	    //layer.full(index);
	}
	function get_load(msg){
		table.reload('items_list', {
			  url: '{:url("sell_stat")}?t=json',
			});
		layer.msg(msg, {icon: 6});
	}
	
	
</script>

</body>
</html>